package com.cn.boot.spring.service.impl;

import com.cn.boot.spring.entity.DepartmentEntity;
import com.cn.boot.spring.mapper.DepartmentMapper;
import com.cn.boot.spring.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Override
    public List<DepartmentEntity> findAll() {
        return departmentMapper.findAll();
    }

    @Override
    public DepartmentEntity findById(Integer id) {
        return departmentMapper.findById(id);
    }

    @Override
    public Integer add(DepartmentEntity departmentEntity) {
        departmentEntity.setId(null);
        return departmentMapper.add(departmentEntity);
    }

    @Override
    public void adds(List<DepartmentEntity> list) {
        list.stream().forEach(departmentMapper::add);
    }

    @Override
    public void del(List<Integer> ids) {
        ids.stream().forEach(departmentMapper::del);
    }

    @Override
    public Integer update(DepartmentEntity departmentEntity) {
        return departmentMapper.update(departmentEntity);
    }
}
